<template>
    <div class="box">
        <Table
            :request="request"
            :config="configTable"
            :propsTable="{}"
            :options="options"
        />
    </div>
</template>

<script>
// 普通搜索查询demo
import Table from "../components/tableCom/index.vue";
import config from "../components/table/config";
import axios from "axios";
import _ from "loadsh"

export default {
    name: "TableDemo",
    data() {
        return {
            request: (params = {}) => {
                return axios.post("/api/page", { ...params }).then(res => {
                    return {
                        list: res?.data?.list,
                        total: res?.data?.total
                    }
                });
            },
            configTable: {},
            options: {},
        }
    },
    methods: {
        init(){
            const obj = _.cloneDeep(config);
            obj.forEach(e => {
                if (e.prop === "action") {
                    e.render = (scope) => <div>
                        <el-button onClick={() => this.handleClick(scope)} type="text">查看</el-button>
                        <el-button type="text">编辑</el-button>
                    </div>
                }
            })
            this.configTable = obj;
        },
        handleClick(val) {
            console.log(val);
        }
    },
    mounted() {
        this.init();
    },
    components: {
        Table
    }
}
</script>